SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO



CREATE VIEW clv_bancos
AS

SELECT	mov.cd_transaccion, mov.nu_transaccion, mov.fe_transaccion,
	mov.cd_banco, ban.nm_banco, mov.nu_cuenta_bancaria, cta.nm_cuenta_bancaria, 
	mov.fe_devengamiento, mov.de_movimiento, mov.st_conciliado,
	mov.cd_estado_trans, mov.nu_chedoctc, mov.fe_chedoctc, tra.tp_mov_banco,
	im_ingreso =case tra.tp_deb_cre when 'D' then mov.im_total else 0 end,
	im_egreso =case tra.tp_deb_cre when 'C' then mov.im_total else 0 end
FROM	cld_mov_bancarios mov
	JOIN wad_transacciones tra ON tra.cd_transaccion =mov.cd_transaccion
	JOIN ccd_bancos ban ON bco.cd_banco =mov.cd_banco
	JOIN cld_cuentas_bancarias cta ON cta.cd_banco =mov.cd_banco AND cta.nu_cuenta_bancaria =mov.nu_cuenta_bancaria



GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

